<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1987-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation.  A copy of
the license is included in the
section entitled "GNU Free Documentation License".

This manual contains no Invariant Sections.  The Front-Cover Texts are
(a) (see below), and the Back-Cover Texts are (b) (see below).

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Macros (The C Preprocessor)</title>

<meta name="description" content="Macros (The C Preprocessor)">
<meta name="keywords" content="Macros (The C Preprocessor)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Index-of-Directives.html" rel="index" title="Index of Directives">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="index.html" rel="up" title="Top">
<link href="Conditionals.html" rel="next" title="Conditionals">
<link href="Header-Files.html" rel="prev" title="Header Files">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en">
<div class="chapter-level-extent" id="Macros">
<div class="nav-panel">
<p>
Next: <a href="Conditionals.html" accesskey="n" rel="next">Conditionals</a>, Previous: <a href="Header-Files.html" accesskey="p" rel="prev">Header Files</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h2 class="chapter" id="Macros-1"><span>3 Macros<a class="copiable-link" href="#Macros-1"> &para;</a></span></h2>

<p>A <em class="dfn">macro</em> is a fragment of code which has been given a name.
Whenever the name is used, it is replaced by the contents of the macro.
There are two kinds of macros.  They differ mostly in what they look
like when they are used.  <em class="dfn">Object-like</em> macros resemble data objects
when used, <em class="dfn">function-like</em> macros resemble function calls.
</p>
<p>You may define any valid identifier as a macro, even if it is a C
keyword.  The preprocessor does not know anything about keywords.  This
can be useful if you wish to hide a keyword such as <code class="code">const</code> from an
older compiler that does not understand it.  However, the preprocessor
operator <code class="code">defined</code> (see <a class="pxref" href="Defined.html">Defined</a>) can never be defined as a
macro, and C++&rsquo;s named operators (see <a class="pxref" href="C_002b_002b-Named-Operators.html">C++ Named Operators</a>) cannot be
macros when you are compiling C++.
</p>

<ul class="mini-toc">
<li><a href="Object_002dlike-Macros.html" accesskey="1">Object-like Macros</a></li>
<li><a href="Function_002dlike-Macros.html" accesskey="2">Function-like Macros</a></li>
<li><a href="Macro-Arguments.html" accesskey="3">Macro Arguments</a></li>
<li><a href="Stringizing.html" accesskey="4">Stringizing</a></li>
<li><a href="Concatenation.html" accesskey="5">Concatenation</a></li>
<li><a href="Variadic-Macros.html" accesskey="6">Variadic Macros</a></li>
<li><a href="Predefined-Macros.html" accesskey="7">Predefined Macros</a></li>
<li><a href="Undefining-and-Redefining-Macros.html" accesskey="8">Undefining and Redefining Macros</a></li>
<li><a href="Directives-Within-Macro-Arguments.html" accesskey="9">Directives Within Macro Arguments</a></li>
<li><a href="Macro-Pitfalls.html">Macro Pitfalls</a></li>
</ul>
</div>



</body>
</html>
